<?php

// 本类由系统自动生成，仅供测试用途
class UserinfoAction extends Action {

    public function index() {
        $user = M('user');
        $condition['username'] = $_SESSION['unick'];
        $userinfo = $user->where($condition)->find();
        $this->assign('userinfo', $userinfo);
        $this->display();
    }

    public function update_userinfo() {
        $user = M('user');
        if ($_POST['name'] == NULL) {
            $this->error('请填写姓名！');
        }
        if ($_POST['phone'] == NULL) {
            $this->error('请填写联系电话！');
        }
        if ($_POST['address'] == NULL) {
            $this->error('请填写店铺地址！');
        }
        $data['id'] = $_SESSION['uid'];
        $data['name'] = $_POST['name'];
        $data['phone'] = $_POST['phone'];
        $data['address'] = $_POST['address'];
        if ($user->save($data)) {
            $this->success('信息修改成功！');
        } else {
            $this->error('信息修改失败！');
        }
    }

}